import os
import re
import argparse

parser = argparse.ArgumentParser(description='传入文件名')
parser.add_argument('name', type=str, help='文件名')
args = parser.parse_args()
name = args.name

try:
    f = open("books\\"+name)
    content=f.read()
    data1 = re.compile(r'[\u0061-\u007a,\u0020-\u003f]')
    en = "".join(data1.findall(content.lower()))
    data2 = re.compile(r'[\u4e00-\u9fa5,\u00d7,\u2013,\u2014,\u2018-\u2027,\u3001,\u3002,\u3003,\u3008-\u3011,\u3014,\u3015,\uff01-\uff0f,\uff1a-\uff20,\uff3b-\uff40,\uff5b-\uff65,\uffe5]')
    cn = "".join(data2.findall(content.lower()))
    f.close()
    f = open("books\\a_EN.txt","w",encoding='utf-8')
    f.write(en)
    f.close()
    f = open("books\\a_CN.txt","w",encoding='utf-8')
    f.write(cn)
    f.close()
except:
    print("文件名错误")